<template>
  <div class="login">
    <div class="left">
      <div class="header">
        <img src="@/assets/img/login_logo.png" alt class="t1" />
        <span class="t2">黑马面面</span>
        <div class="t3"></div>
        <span class="t4">用户登录</span>
      </div>
      <el-form class="form" :model="form" :rules="rules" ref="form">
        <el-form-item>
          <el-input
            placeholder="请输入手机号"
            prefix-icon="el-icon-user"
            v-model="form.phone"
            prop="phone"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            placeholder="请输入密码"
            prefix-icon="el-icon-lock"
            show-password
            v-model="form.password"
            prop="password"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-row>
            <el-col :span="16">
              <el-input
                placeholder="请输入验证码"
                prefix-icon="el-icon-lock"
                show-password
                v-model="form.code"
                prop="code"
              ></el-input>
            </el-col>
            <el-col :span="8">
              <img :src="baseUrl+'/captcha?type=sendsms'" alt class="code-img" />
            
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item prop="isCheck">
          <el-checkbox v-model="form.isCheck">
            我已阅读并同意
            <el-link type="primary">用户协议</el-link>和
            <el-link type="primary">隐私条款</el-link>
          </el-checkbox>
        </el-form-item>
        <el-form-item>
          <el-button class="btn" type="primary" @click="submit">登录</el-button>
          <div></div>
          <el-button class="btn m26" type="primary" @click="showRegister">注册</el-button>
        </el-form-item>
      </el-form>
    </div>
    <img src="@/assets/img/login_banner_ele.png" alt />
    <register ref="register" />
  </div>
</template>

<script>
import register from './register'
export default {
  components:{
    register
  },
  data() {
    return {
      baseUrl:process.env.VUE_APP_URL,
      form: {
        phone: "",
        password: "",
        code: "",
        isChecked: false,
      },
      rules: {
        name: [
          { required: true, message: "用户名不能为空", trigger: "blur" },
          {
            min: 6,
            max: 12,
            message: "长度在 6 到 12 个字符",
            trigger: "blur",
          },
        ],
        password: [
          { required: true, message: "密码不能为空", trigger: "blur" },
          { min: 6, max: 8, message: "长度在 6 到 8 个字符", trigger: "blur" },
        ],
        code: [
          {
            required: true,
            min: 4,
            max: 4,
            message: "请填入验证码！",
            trigger: "change",
          },
        ],
        isCheck: [
          { required: true, message: "请填入用户名！", trigger: "change" },
        ],
      },
    };
  },
    methods: {
      showRegister(){
        this.$refs.register.dialogVisible=true
      },
    submit() {
      window.console.log(this.form);
      this.$refs.form.validate(result => {
        window.console.log(result);
      });
    }
  },

};
</script>

<style lang="less">
.login {
  height: 100%;
  background: linear-gradient(#1493fa 28%, #01c6fa 96%);
  display: flex;
  align-items: center;
  justify-content: space-around;
  .left {
    width: 478px;
    height: 550px;
    background: #f5f5f5;
    padding: 44px 42px;
    .header {
      display: flex;
      align-items: center;
      .t1 {
        width: 25px;
      }
      .t2 {
        font-size: 24px;
        font-family: SourceHanSansCN Regular, SourceHanSansCN Regular-Regular;
        font-weight: 400;
        text-align: left;
        color: #0c0c0c;
        margin-left: 14px;
        margin-right: 14px;
      }
      .t3 {
        width: 1px;
        height: 28px;
        background: #c7c7c7;
        margin-right: 14px;
      }
      .t4 {
        font-size: 22px;
        font-family: PingFangSC Regular, PingFangSC Regular-Regular;
        font-weight: 400;
        text-align: left;
        color: #0c0c0c;
      }
    }
    .form {
      margin-top: 30px;
      .code-img {
        width: 100%;
        height: 40px;
      }
      .btn {
        width: 100%;
      }
      .m26 {
        margin-top: 26px;
      }
    }
  }
}
</style>